﻿using System.Collections;
using System.Collections.Generic;
using Cinemachine;
using UnityEngine;
using UnityEngine.Playables;
using UnityEngine.Timeline;

public class CarTimelineSystem : MonoBehaviour
{
    public PlayableDirector cTrack;
    private PlayableBinding cBinding;
    
    public void SetCamera(CinemachineBrain cam)
    {
        if (cBinding.sourceObject == null)
        {
            foreach (var bind in cTrack.playableAsset.outputs)
            {
                if (bind.streamName == "Cinemachine Track")
                {
                    cBinding.sourceObject = bind.sourceObject;
                }
            }
        }
        cTrack.SetGenericBinding(cBinding.sourceObject,cam);
    }
    
    public void Stop()
    {
        gameObject.SetActive(false);
    }

    public void Start()
    {
        cTrack.time = 0;
        gameObject.SetActive(true);
    }
}
